
/*
 * HadoopReducer.java
 *
 * Created on May 13, 2012, 4:00:10 PM
 */

package CountC;


import java.io.IOException;
import java.util.Iterator;
// import org.apache.commons.logging.Log;
// import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;

/**
 *
 * @author crazymooner
 */
public class HadoopReducer extends MapReduceBase implements Reducer<IntWritable,IntWritable,Text,IntWritable> {
    // The Karmasphere Studio Workflow Log displays logging from Apache Commons Logging, for example:
    // private static final Log LOG = LogFactory.getLog("CountC.HadoopReducer");

	@Override
    public void reduce(IntWritable key, Iterator<IntWritable> value, OutputCollector<Text, IntWritable> output, Reporter reporter)
            throws IOException {
		int count = 0;
		while(value.hasNext()){
			value.next();
			count++;
		}
		output.collect(new Text("Component Num: "), new IntWritable(count));
    }
}
